class VideoCommentsController < ApplicationController
  before_filter :authenticate
  
  # GET /video_comments
  # GET /video_comments.xml
  def index
    @video_comments = VideoComment.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @video_comments }
    end
  end

  # GET /video_comments/1
  # GET /video_comments/1.xml
  def show
    @video_comment = VideoComment.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @video_comment }
    end
  end

  # GET /video_comments/new
  # GET /video_comments/new.xml
  def new
    @video_comment = VideoComment.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @video_comment }
    end
  end

  # GET /video_comments/1/edit
  def edit
    @video_comment = VideoComment.find(params[:id])
  end

  # POST /video_comments
  # POST /video_comments.xml
  def create
    @video_comment = VideoComment.new(params[:video_comment])

    respond_to do |format|
      if @video_comment.save
        format.html { redirect_to(url_for(:controller => "videos", :action => "details", :id => @video_comment.video_id ), :notice => 'Video comment was successfully created.') }
        format.xml  { render :xml => @video_comment, :status => :created, :location => @video_comment }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @video_comment.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /video_comments/1
  # PUT /video_comments/1.xml
  def update
    @video_comment = VideoComment.find(params[:id])

    respond_to do |format|
      if @video_comment.update_attributes(params[:video_comment])
        format.html { redirect_to(@video_comment, :notice => 'Video comment was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @video_comment.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /video_comments/1
  # DELETE /video_comments/1.xml
  def destroy
    @video_comment = VideoComment.find(params[:id])
    @video_comment.destroy

    respond_to do |format|
      format.html { redirect_to(video_comments_url) }
      format.xml  { head :ok }
    end
  end
end
